#!/usr/bin/python
#-*-coding: utf-8 -*-

__all__ = [u'cg_make']

from pylot.core import (check_type, cpu_count, CommandGroup)

def cg_make (target, build_dir) :
  u"""
  Creates a :class:`~pylot.core.CommandGroup` that 'makes' program. 
  You must be in build dir.

  :param target: :program:`make` target ('', 'install', 'doc', 'clean', ...)
  :type target: str
  """
  try :
    cpu = cpu_count()
  except NotImplementedError :
    cpu = 1

  command_group = CommandGroup(u'Make', u'Make %s' % target, u'Build')
  command_group.working_directory = build_dir
  args = [u'-j', cpu]
  if target :
    args.append(target)
  command_group.addShellCmd(u'make', args)

  return command_group

if __name__ == '__main__' :
  pass
